package com.tsmti.system.entity;


import com.tsmti.core.common.entity.AbstractEntity;
import com.tsmti.core.common.entity.BaseDataEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
 * @Package：com.tsmti.system.entity
 * @Class：UserOnline
 * @Description： 用户机构
 * @Author：zcw
 * @Date：Created in 2018/1/30 18:12
 * @Company:
 * @Version：
 * @Modified By:
 */
@Entity
@Table(name = "pims_user_organization")
@DynamicUpdate
@DynamicInsert
@SuppressWarnings("serial")
public class UserOrganization extends AbstractEntity<Long> {
    /** 编号 */
    private Long id;
    /** 用户编号 */
    private Long userId;
    /** 用户 */
    private User user;
    /** 机构编码 */
    private Long organizationId;
    /** 机构 */
    private Organization organization;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_ORGANIZATION")
    @SequenceGenerator(name = "SEQ_ORGANIZATION", sequenceName = "organization_sequence", allocationSize = 1)
    @Override
    public Long getId() {
        return this.id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @ManyToOne
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "userId", nullable = false, updatable = false, insertable = false)
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }





    public Long getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(Long organizationId) {
        this.organizationId = organizationId;
    }

    @ManyToOne
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "organizationid", nullable = false, updatable = false, insertable = false)
    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

}
